import Vue from 'vue'
import Router from 'vue-router'
import Main from '../view/form/Main'
import Menu from '../view/form/childcomps/Menu'
import Foodinsert from '../view/form/childcomps/Foodinsert'
import Bill from '../view/form/childcomps/Bill'
import Information from '../view/form/childcomps/Information'
import History from '../view/form/childcomps/History'
import Introduction from '../view/form/childcomps/Introduction'
import Login from '../view/form/LoginView'
import Regist from '../view/form/RegistView'
import MainRoot from "../view/form/MainRoot";
import MenuRoot from "../view/form/childcomps/MenuRoot";
import UserManage from "../view/form/childcomps/UserManage";
import InformationRoot from "../view/form/childcomps/InformationRoot";
import HistoryRoot from "../view/form/childcomps/HistoryRoot";

// 安装路由
Vue.use(Router)

   const routes = [
    {
      path: '/',
      redirect: '/form/login'
    },
    {
      path: '/form/main',
      name: 'main',
      component: Main,
      children: [
        {
          path: '/form/childcomps/menu',
          component: Menu
        },
        {
          path: '/form/childcomps/introduction',
          component: Introduction
        },
        {
          path: '/form/childcomps/information',
          component: Information
        },
        {
          path: '/form/childcomps/history',
          component: History
        }
      ]
    },
     {
       path: '/form/mainroot',
       component: MainRoot,
       children: [
         {
           path: '/form/childcomps/menuroot',
           component: MenuRoot
         },
         {
           path: '/form/childcomps/introduction',
           component: Introduction
         },
         {
           path: '/form/childcomps/foodinsert',
           component: Foodinsert
         },
         {
           path: '/form/childcomps/bill',
           component: Bill
         },
         {
           path: '/form/childcomps/informationroot',
           component: InformationRoot
         },
         {
           path: '/form/childcomps/usermanage',
           component: UserManage
         },
         {
           path: '/form/childcomps/historyroot',
           component: HistoryRoot
         }
       ]
     },
    {
      path: '/form/login',
      component: Login
    },
    {
      path: '/form/regist',
      component: Regist
    }
  ];

const router = new Router({
  routes
});
// router.beforeEach((to,from,next) =>{
//   if(to.path == '/form/login' || to.path=='/form/register'){
//     next();
//   }else if(localStorage.getItem("Authorization")!=null){
//     next();
//   }else{
//     next({path:'/form/login'});
//   }
// });

export default router
